package com.wufan.day05.java2;

/**
 * this关键字的使用
 * @author SongWufan
 * @date 2021/3/9 23:11
 */
public class PersonTest {
    public static void main(String[] args) {
        Person person = new Person("tzq",12);
        System.out.println(person.getName()+"\t"+person.getAge());
        person.eat();
        System.out.println();
        Person person1 = new Person("WUFAN",22);
        System.out.println(person1.getAge());
    }
}

class Person{
    private String name;
    private int age;

    public Person(String name, int age) {
        this(age);
        this.name = name;
        this.age = age;
    }

    public Person(String name) {
        this();
        this.name = name;
    }

    public Person(int age) {
        this();
        this.age = age;
    }
    public Person() {
        System.out.println("初始化");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void eat() {
        System.out.println("吃饭");
        this.study();
    }

    public void study() {
        System.out.println("学习");
    }
}
